<?php
/**
 *　                  oooooooooooo
 *
 *                  ooooooooooooooooo
 *                       o
 *                      o
 *                     o        o
 *                    oooooooooooo
 *
 *         ～～         ～～         　　～～
 *       ~~　　　　　~~　　　　　　　　~~
 * ~~～~~～~~　　　~~~～~~～~~～　　　~~~～~~～~~～
 * ·······              ~~XYHCMS~~            ·······
 * ·······  闲看庭前花开花落 漫随天外云卷云舒 ·······
 * ·············     www.xyhcms.com     ·············
 * ··················································
 * ··················································
 *
 * @Author: gosea <gosea199@gmail.com>
 * @Date:   2014-06-21 10:00:00
 * @Last Modified by:   gosea
 * @Last Modified time: 2017-05-30 17:56:40
 */
namespace PingNa\Controller;

use Think\Controller;
use Think\Think;

//公共验证控制器HomeCommonController
class HomeCommonController extends Controller
{
    public $uid;
    public $email;
    public $uf;//标识
    public $layout;
    public $logoId = 16; ///品牌LOGO
    public $headHtml;
    public $footHtml;
    // 空操作，404页面
    public function _empty()
    {
        header("HTTP/1.1 404 Not Found");
        header("Status: 404 Not Found");
        $pageRount =  C('errorPage'); //获取404页面路径
        $t = Think::instance('Think\Template'); //初始化模板文件
        $t->fetch($pageRount,''); //渲染文件
        $content = ob_get_clean(); //清空缓存并且获取内容
        print_r($content);
    }

    protected function _initialize()
    {
        $this->uid = intval(get_cookie('uid'));     
        $this->email = get_cookie('email'); 
        $this->uf = get_cookie('uf');
        if (C('CFG_WEBSITE_CLOSE') == 1) {
            exit_msg(C('CFG_WEBSITE_CLOSE_INFO'));
        }
        if(!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
            $this->email = '';
        }

    }

    /*
     * 防止被刷
     */
    public function _unflish(){
        $allow_sep = "4"; //防止刷新时间
        $ip = get_client_ip();
        $session = S($ip);
        $time = time();
        if(time()-$session < $allow_sep){
            $info = [
                'code'=>2,
                'msg'=>"休息4秒再提交吧"
            ];
            print_r(JSON_encode($info));
            S($ip,$time);
            exit;
        }
    }
    public $t = false;
    /*
     * $rount：渲染文件路径
     * $inputContent：插入内容
     */
    public function getTemplatePage($rount = '',$inputContent=''){
        $pageRount = C('templateRount');
        if(!empty($rount)){
            $pageRount.= $rount;
        }else{
            $pageRount.= 'header.html';
        }
        $content = $this->fetch($pageRount);
        return $content;
    }



}
